package com.vma.inter.controller.lottery;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.vma.advertisement.model.Advertisement;
import com.vma.advertisement.model.Message;
import com.vma.inter.util.ReturnsUtil;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by chenzui on 2017/3/29.
 */
public class AdvertiseController extends Controller {

    public void qryAdList(){
        try{
            List<Advertisement> list = Advertisement.dao.find("select id,imgUrl,if_link,title,type,url from advertisement where if_delete = 0" +
                    " and a_status = 1 and type = 2 order by create_time desc");
            renderJson(ReturnsUtil.returnSuccess(list));
        }catch (Exception e){
            e.printStackTrace();
            renderJson(ReturnsUtil.returnException(e.getMessage(),e));
        }

    }

    public void qryMessageList(){
        try{
            List<Message> list = Message.dao.find("select id,content,url from message WHERE if_delete=0 AND a_status =1" +
                    " order by create_time desc");
            renderJson(ReturnsUtil.returnSuccess(list));
        }catch (Exception e){
            e.printStackTrace();
            renderJson(ReturnsUtil.returnException(e.getMessage(),e));
        }

    }

    public void getAd(){
        Advertisement advertisement = Advertisement.dao.findById(getPara("id"));
        setAttr("advertisement",advertisement);
        renderJsp("/adver/ad.jsp");
    }

}
